package com.xinke.module.system.mapper.mail;

import java.util.*;

import com.xinke.component.common.pojo.PageResult;
import com.xinke.component.mybatis.mybatis.core.query.LambdaQueryWrapperExt;
import com.xinke.component.mybatis.mybatis.core.mapper.BaseMapperExt;
import com.xinke.module.system.model.entity.mail.MailAccountDO;
import org.apache.ibatis.annotations.Mapper;
import com.xinke.module.system.model.vo.mail.*;

/**
 * 邮箱账号 Mapper
 *
 * @author yzx
 */
@Mapper
public interface MailAccountMapper extends BaseMapperExt<MailAccountDO> {

    default PageResult<MailAccountDO> selectPage(MailAccountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperExt<MailAccountDO>()
                .eqIfPresent(MailAccountDO::getMailAddress, reqVO.getMailAddress())
                .likeIfPresent(MailAccountDO::getUserName, reqVO.getUserName())
                .eqIfPresent(MailAccountDO::getPassword, reqVO.getPassword())
                .eqIfPresent(MailAccountDO::getSmtpHost, reqVO.getSmtpHost())
                .eqIfPresent(MailAccountDO::getSmtpPort, reqVO.getSmtpPort())
                .eqIfPresent(MailAccountDO::getSslEnable, reqVO.getSslEnable())
                .eqIfPresent(MailAccountDO::getStarttlsEnable, reqVO.getStarttlsEnable())
                .orderByDesc(MailAccountDO::getMailAcctId));
    }

}